//- Copyright (c) 2016 Lucky Byte, Inc.
extends ./layout

append css
  link(href='/css/log.css', rel='stylesheet', type='text/css')

  style(type="text/css").
    .segment#log {
      padding-top: 2px;
      padding-bottom: 2px;
      padding-right: 0px;
      padding-left: 8px;
    }
    pre#log {
      margin: 0px;
    }
    code#log {
      word-wrap: break-word;
      white-space: pre-wrap;
      font-weight: 500;
    }

append scripts
  script(src="/js/logs.js")


block content
  .ui.grid(style="margin-left:10px; margin-right:0px;")
    .column.three.wide.nolayout(style="margin-top:20px;")
      .ui.raised.segment.brown
        .ui.label.ribbon.large.grey
          i.icon.file.text.outline
          | 日志文件
        .ui.divided.relaxed.small.middle.aligned.list
          .item
            .right.floated.content
              .ui.label.green.small(
                style="padding:6px; padding-top:2px; padding-bottom:3px;")= pos091_size || '未知'
            i.icon.red(style="padding-top:2px;"
              class="#{path == 'luckpay_091' ? 'arrow right' : ''}")
            .content(style="padding-top:2px;")
              a(href="/logs/luckpay_091") POS 009.1
          .item
            .right.floated.content
              .ui.label.green.small(
                style="padding:6px; padding-top:2px; padding-bottom:3px;")= servlet_size || '未知'
            i.icon.red(style="padding-top:2px;"
              class="#{path == 'luckpay_servlet' ? 'arrow right' : ''}")
            .content(style="padding-top:2px;")
              a(href="/logs/luckpay_servlet") SERVLET
          .item
            .right.floated.content
              .ui.label.green.small(
                style="padding:6px; padding-top:2px; padding-bottom:3px;")= sched_size || '未知'
            i.icon.red(style="padding-top:2px;"
              class="#{path == 'luckpay_sched' ? 'arrow right' : ''}")
            .content(style="padding-top:2px;")
              a(href="/logs/luckpay_sched") SCHEDULER
          .item
            .right.floated.content
              .ui.label.green.small(
                style="padding:6px; padding-top:2px; padding-bottom:3px;")= tpdu_size || '未知'
            i.icon.red(style="padding-top:2px;"
              class="#{path == 'tpdu' ? 'arrow right' : ''}")
            .content(style="padding-top:2px;")
              a(href="/logs/tpdu") TPDU
          .item
            .right.floated.content
              .ui.label.green.small(
                style="padding:6px; padding-top:2px; padding-bottom:3px;")= jdbc_size || '未知'
            i.icon.red(style="padding-top:2px;"
              class="#{path == 'jdbc' ? 'arrow right' : ''}")
            .content(style="padding-top:2px;")
              a(href="/logs/jdbc") JDBC

    .column.thirteen.wide
      form.ui.form.attached.segment#search_form(method="post" action="/logs/#{path}")

        .fields
          .field.three.wide#keyword
            .ui.search
              .ui.icon.input
                input.prompt(type="text" name="keyword" value="#{keyword}"
                  placeholder="输入关键字回车查询")
                i.search.link.icon

          .field.two.wide
            .ui.labeled.dropdown.selection.input
              input(type="hidden" name="level" value="#{level || ''}")
              i.icon.dropdown
              .default.text 跟踪级别
              .menu
                .item(data-value="TRACE") 跟踪级别
                .item(data-value="DEBUG") 调试级别
                .item(data-value="INFO") 信息级别
                .item(data-value="WARN") 警告级别
                .item(data-value="ERROR") 错误级别
                .item(data-value="FATAL") 严重级别

          .field.three.wide
            .ui.labeled.dropdown.selection.input
              input(type="hidden" name="max_lines" value="#{max_lines || ''}")
              i.icon.dropdown
              .default.text 显示 500 行
              .menu
                .item(data-value="500") 显示 500 行
                .item(data-value="1000") 显示 1000 行
                .item(data-value="1500") 显示 1500 行
                .item(data-value="2000") 显示 2000 行
                .item(data-value="3000") 显示 3000 行
                .item(data-value="5000") 显示 5000 行

          .field.two.wide
            .ui.input.left.icon.search
              i.ordered.list.icon
              input(type="text" name="start_no" placeholder="起始行号"
                value="#{start_no > 0 ? start_no : ''}")

          .field.six.wide
            button.ui.right.floated.green.labeled.icon.button(type="submit")
              i.icon.search
              | 刷 新

      .ui.bottom.attached.segment.log#log
        pre#log
          code#log
            each line in lines
              - var color = 'darkblue'
              case line.level
                when 'TRACE'
                  - color = 'darkgrey'
                when 'DEBUG'
                  - color = '#44aa44'
                when 'INFO'
                  - color = 'black'
                when 'WARN'
                  - color = '#e44c00'
                when 'ERROR'
                  - color = 'red'
                when 'FATAL'
                  - color = 'fuchsia'

              span(style="color:goldenrod;") #{line.line_no || 0} 
              span #{line.time} 
              span(style="color:#{color};") [#{line.thread} #{line.logger}] #{line.level} - #{line.message}
              br
